<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let str = '111 222 333 ';
        // 1 正则表达式+replace
        // let reg =/\s/g
        //cosole.log(str.replace(reg,''))
        //数组api的filter
        let strList = str.split('')
        let result = strList.filter(item => {
            return item !== ''
        })
        console.log(strList)
        console.log(result.join(''))
    </script>
</body>
</html>